<?php

require_once('lib/ImapMailbox.php');

// IMAP must be enabled in Google Mail Settings
//define('GMAIL_EMAIL', 'info.bytefact@gmail.com');
//define('GMAIL_PASSWORD', 'byt3fact');
//define('ATTACHMENTS_DIR', dirname(__FILE__) . '/attachments');

//$mailbox = new ImapMailbox('{imap.gmail.com:993/imap/ssl}INBOX', GMAIL_EMAIL, GMAIL_PASSWORD, ATTACHMENTS_DIR, 'utf-8');
//$mailbox = new ImapMailbox('{imap.gmail.com:993/imap/ssl}INBOX', 'info.bytefact@gmail.com', 'byt3fact', dirname(__FILE__) . '/attachments', 'utf-8');
//$socket = fsockopen("imap.mail.yahoo.com", "80", $errno, $errstr,10); 
if(true) 
{
    $mailbox = new ImapMailbox('{takethemail.com:143/imap/novalidate-cert}INBOX', 'admin@takethemail.com', 'byt3fact');
    $mails = array();

    // Get some mail
    $mailsIds = $mailbox->searchMailBox('UNSEEN');
    if(!$mailsIds) {
        die('Mailbox is empty');
    }
    echo "##################################################";
    var_dump($mailsIds);
    echo "####################################################";

    //$mailId = max($mailsIds);
    //echo "mail id is :".$mailId;
    //$mail = $mailbox->getMail($mailId);
    //$mailId = min($mailsIds);
    //$mail = $mailbox->getMail($mailId);
    $header = $mailbox->getMailsInfo($mailsIds);
    echo "<pre>";
    var_dump($header);
    echo "</pre>";
    //var_dump($mail->getAttachments());
}
else {
    echo "Connection failed!<br /><br />"; 
}

?>